package com.zabra.zl.ui.verifybank;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.orhanobut.logger.Logger;
import com.zabra.zl.R;
import com.zabra.zl.base.BaseMvpActivity;
import com.zabra.zl.data.EventMessage;
import com.zabra.zl.ui.deposit.DepositActivity;
import com.zabra.zl.ui.mybank.MyBankActivity;
import com.zabra.zl.ui.verifybank.contract.VerifyBankContract;
import com.zabra.zl.ui.verifybank.presenter.VerifyBankPresenter;
import com.zabra.zl.utils.ToastUtil;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 验证银行卡
 */
public class VerifyBankActivity extends BaseMvpActivity<VerifyBankPresenter> implements VerifyBankContract.View {

    @BindView(R.id.back)
    LinearLayout back;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.et_phone)
    EditText etPhone;
    @BindView(R.id.et_vercode)
    EditText etVercode;
    @BindView(R.id.tv_getcode)
    TextView tvGetcode;
    @BindView(R.id.tv_submit)
    TextView tvSubmit;
    private String strMessage;

    @Override
    public int getLayoutId() {
        return R.layout.activity_verify_bank;
    }

    @Override
    public void initView() {
        tvTitle.setText("验证银行卡");

    }

    @Override
    protected void onStart() {
        super.onStart();
        EventBus.getDefault().register(this);
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void onError(Throwable throwable) {

    }

    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void onReceiveMsg(EventMessage message) {
        strMessage = message.getMessage();
    }

    @OnClick({R.id.back, R.id.tv_getcode, R.id.tv_submit})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.tv_getcode:
                break;
            case R.id.tv_submit:
                if (strMessage.equals("MyBank")||strMessage.equals("Person")) {
                    //跳转到银行卡界面
                    toClass_EmptyTop(this, MyBankActivity.class);
                }
                if (strMessage.endsWith("Deposit")) {
                    //跳转到提现界面
                    toClass_EmptyTop(this, DepositActivity.class);
                }
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
